package com.pyip.reggie.controller;

import com.pyip.reggie.Entity.User;
import com.pyip.reggie.common.R;
import com.pyip.reggie.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;


    /**
     * 根据用户的电话号码发送短信验证码
     * @param user
     * @param session
     * @return
     */
    @RequestMapping(value = "/sendMsg",method = RequestMethod.POST)
    public R<String> sendMessage(@RequestBody User user, HttpSession session){
        return userService.sendMessage(user,session);
    }

    /**
     * 用户登陆
     * @param map
     * @param session
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public R<User> login(@RequestBody Map<String,String> map, HttpSession session){
        return userService.login(map,session);
    }
}
